package com.surprise.db.dao.join;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.surprise.db.dao.SimpleDAO;
import com.surprise.db.entity.join.SelectPMThingsCommentMst002Entity;

/**
 * SelectPMThingsCommentMst002.java
 * @author xuling
 * @since 2017年2月14日
 */
@Repository
public class SelectPMThingsCommentMst002 extends SimpleDAO<SelectPMThingsCommentMst002Entity> {

	/**
	 * 获得那些事未阅读的评论
	 * @param userid 用户ID
	 * @return 那些事的评论
	 */
	public List<SelectPMThingsCommentMst002Entity> select(Long userid) {
		String sql = " SELECT pm_things_comment_mst.id, " +
				" pm_things_comment_mst.userid, " +
				" pm_things_comment_mst.thingsid, " +
				" pm_things_comment_mst.img, " +
				" pm_things_comment_mst.content, " +
				" user.username as username, " +
				" user.portrait as portrait, " +
				" pm_things_mst.content as thingsContent " +
				" FROM pm_things_comment_mst INNER JOIN " +
				" user on user.id = pm_things_comment_mst.userid  " +
				" INNER JOIN pm_things_mst on pm_things_mst.id = pm_things_comment_mst.thingsid " +
				" AND pm_things_mst.userid = ? AND pm_things_mst.deleteflg = 0 " +
				" WHERE pm_things_comment_mst.readflg = 0 ";
		return super.findBySql(sql, userid);
	}
}
